home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / tex / macros / latex / doc / bezier.doc < prev    next >
Text File  |  1992-03-18  |  4KB  |  125 lines

  1. % BEZIER DOCUMENT-STYLE OPTION - released 17 December 1985
  2. %    for LaTeX version 2.09
  3. % Copyright (C) 1985 by Leslie Lamport
  4.  
  5. %  In a picture environment, writing
  6. %
  7. %       \bezier{N}(AX,AY)(BX,BY)(CX,CY)
  8. %
  9. %  plots a quadratic Bezier curve from (AX,AY) to (CX,CY), with (BX,BY)
  10. %  as the third Bezier point, using N+1 equally spaced points.
  11. %
  12. %  \bezier{N}(AX,AY)(BX,BY)(CX,CY) ==
  13. %    BEGIN
  14. %      @sc  := N
  15. %      @scp := @sc+1
  16. %      \@xb := 2 * (BX - AX) * \unitlength
  17. %      \@xa := ((CX-AX)*\unitlength - \@xb)/@sc
  18. %      \@yb := 2 * (BY - AY) * \unitlength
  19. %      \@ya := ((CY-AY)*\unitlength - \@yb)/@sc
  20. %      \@pt := square rule of width \@wholewidth
  21. %      @t := 0
  22. %      WHILE @t < @scp
  23. %        DO  \@x := ((@t*\@xa + @xb) / @sc) * t
  24. %            \@y := ((@t*\@ya + @yb) / @sc) * t
  25. %            plot pt with relative coords (\@x,\@y)
  26. %            @t := @t+1
  27. %        OD
  28.  
  29. \newcounter{@sc}
  30. \newcounter{@scp}
  31. \newcounter{@t}
  32. \newlength{\@x}
  33. \newlength{\@xa}
  34. \newlength{\@xb}
  35. \newlength{\@y}
  36. \newlength{\@ya}
  37. \newlength{\@yb}
  38. \newsavebox{\@pt}
  39.  
  40. \def\bezier#1(#2,#3)(#4,#5)(#6,#7){\c@@sc#1\relax
  41.   \c@@scp\c@@sc \advance\c@@scp\@ne
  42.   \@xb #4\unitlength \advance\@xb -#2\unitlength \multiply\@xb \tw@
  43.   \@xa #6\unitlength \advance\@xa -#2\unitlength
  44.       \advance\@xa -\@xb \divide\@xa\c@@sc
  45.   \@yb #5\unitlength \advance\@yb -#3\unitlength \multiply\@yb \tw@
  46.   \@ya #7\unitlength \advance\@ya -#3\unitlength
  47.       \advance\@ya -\@yb \divide\@ya\c@@sc
  48.   \setbox\@pt\hbox{\vrule height\@halfwidth  depth\@halfwidth
  49.    width\@wholewidth}\c@@t\z@
  50.    \put(#2,#3){\@whilenum{\c@@t<\c@@scp}\do
  51.       {\@x\c@@t\@xa \advance\@x\@xb \divide\@x\c@@sc \multiply\@x\c@@t
  52.        \@y\c@@t\@ya \advance\@y\@yb \divide\@y\c@@sc \multiply\@y\c@@t
  53.        \raise \@y \hbox to \z@{\hskip \@x\unhcopy\@pt\hss}%
  54.        \advance\c@@t\@ne}}}
  55.  
  56.  
  57. %  of commands of the type specified below, does the following,
  58. %  where t, dt, dx, and dy are counters,
  59. %
  60. %        t  := 0
  61. %        dt := DT
  62. %        dx := 0
  63. %        dy := 0
  64. %        WHILE t < MAX
  65. %          DO  plot the point (X + (dx/SCALE)), Y + (dy/SCALE))
  66. %              t := t + dt
  67. %              execute COMMANDS
  68. %          OD
  69. %
  70. % COMMANDS may include only the commands \set, \add, \mul, or \div,
  71. % defined as follows, where
  72. %           CTR == counter name,
  73. %           VAL == either an integer (like 2145 or -7), or
  74. %                  \value{CTR'}, where CTR' a counter name, or
  75. %                  -\value{CTR'}
  76. %
  77. %      \set{CTR}{VAL}
  78. %         This command performs the operation  CTR := VAL
  79. %
  80. %      \add{CTR}{VAL}
  81. %          Performs the operation  CTR := CTR + VAL
  82. %
  83. %      \mul{CTR}{VAL}
  84. %          Performs the operation  CTR := CTR * VAL
  85. %
  86. %      \div{CTR}{VAL}
  87. %          Performs the operation  CTR := CTR / VAL
  88. %          (this is integer division, with 5/3 = 1 and
  89. %           -5/3 = 5/(-3) = -1)
  90. %
  91. %  There should be no spaces in COMMANDS.  However, the command \  can
  92. %  be used for readabiilty--e.g.,
  93. %       \set{foo}{dt}\  \mul{foo}{3}
  94. %
  95. %
  96. %  HINTS:
  97. %    \plot'ing takes a long time, so start with DT large, and make it
  98. %     small only for the final draft.
  99. %
  100.  
  101. %\newcounter{t}
  102. %\newcounter{dt}
  103. %\newcounter{dx}
  104. %\newcounter{dy}
  105. %
  106. %\def\set#1#2{\csname c@#1\endcsname#2}
  107. %\def\@div#1#2{\divide\csname c@#1\endcsname#2}
  108. %\def\mul#1#2{\multiply\csname c@#1\endcsname#2}
  109. %\def\add#1#2{\advance\csname c@#1\endcsname#2}
  110. %
  111.  
  112.  
  113.  
  114. %\def\plot#1#2#3#4{\let\div\@div \def\ {}\c@t\z@ \c@t\z@
  115. %  \c@dt#1\c@dx\z@ \c@dy\z@\edef\@tempa{#4}\@tempdima\unitlength
  116. %  \divide\@tempdima #3\relax
  117. %  \setbox\@pt\hbox{\vrule height\@halfwidth  depth\@halfwidth
  118. %   width\@wholewidth}\@whilenum{\c@t<#2}\do
  119. %  {\raise \c@dy\@tempdima \hbox to \z@{\hskip \c@dx\@tempdima
  120. %                                       \unhcopy\@pt\hss
  121. %                                      }\advance\c@t\c@dt\@tempa}}
  122. %
  123.  
  124. \endinput
  125.